﻿//  Copyright (c) 2011 Ray Liang (http://www.dotnetage.com)
//  Licensed MIT: http://www.opensource.org/licenses/mit-license.php

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace DNA.Mvc.Publishing
{
    /// <summary>
    /// Provides the methods to operate publishing objects.
    /// </summary>
    public interface IPubService
    {
        #region Category methods

        /// <summary>
        /// Find category by specified category id.
        /// </summary>
        /// <param name="id">The category id.</param>
        /// <returns>Returns the Category object. Returns null value when category not found </returns>
        Category FindCategory(int id);

        /// <summary>
        /// Find Category object by specified category path.
        /// </summary>
        /// <example>
        ///  FindCategory("home/articles");
        /// </example>
        /// <param name="path">The category path.</param>
        /// <returns>Returns the Category object. Returns null value when category not found </returns>
        Category FindCategory(string path);

        /// <summary>
        /// Update or add new category.
        /// </summary>
        /// <remarks>
        /// When input category.ID equal 0 will create a new create.
        /// </remarks>
        /// <param name="category">The category to update.</param>
        /// <returns>The updated category object.</returns>
        Category UpdateCategory(Category category);

        /// <summary>
        /// Delete category by specified category id.
        /// </summary>
        /// <param name="id">The category id.</param>
        void DeleteCategory(int id);

        /// <summary>
        /// Get categorys in specified id array.
        /// </summary>
        /// <param name="ids">The array contains category ids.</param>
        /// <returns>Returns the category collection.</returns>
        IEnumerable<Category> GetCategories(int[] ids);

        /// <summary>
        /// Get suggest categories.
        /// </summary>
        /// <param name="prefix"></param>
        /// <param name="returns"></param>
        /// <returns></returns>
        IEnumerable<Category> GetSuggestCategories(string prefix, int returns);

        /// <summary>
        /// Get all categories by specified website.
        /// </summary>
        /// <param name="website">The website name.</param>
        /// <returns></returns>
        IEnumerable<Category> GetCategories(string website);

        IEnumerable<Category> GetChildrenCategories(int id);

        /// <summary>
        /// Returns categories of article.
        /// </summary>
        /// <param name="articleID">The article id.</param>
        /// <returns></returns>
        IEnumerable<Category> GetPostCategories(int articleID);

        #endregion

        #region Post methods

        Article NewPost(Article article,bool isAdmin=false);

        Article NewPost(string website, Article article, string[] categoryNames);

        void EditPost(Article article);

        void MovePost(int id, int pos, int categoryID);

        void DeletePost(int id);

        void ReadPost(int id, string username, string ip, string userAgent);

        double Vote(int id, int value, string userName, string ip, out int total);

        Article GetPost(int id);

        IEnumerable<Article>  GetPosts(int[] ids);

        Article GetPrevSiblingArticle(Article article);

        Article GetNextSiblingArticle(Article article);

        IEnumerable<Article> GetHotPosts(string website, int maxResults);

        IQueryable<Article> GetDescendantArticles(int categoryId);
        
        IEnumerable<Article> GetArchivePosts(string website, int year, int month);

        IEnumerable<Article> GetArchivePosts(string website, int year, int month, int pageIndex, int pageSize, out int totalRecords);
        
        IEnumerable<Article> GetTagPosts(string website, string tagName,int pageIndex,int pageSize,out int totalRecords);

        IEnumerable<Article> GetUnapprovePosts(string website, int pageIndex, int pageSize, out int totalRecords);

        IEnumerable<Article> GetUserUnapprovePosts(string username, int pageIndex, int pageSize, out int totalRecords);

        IEnumerable<Article> GetDrafts(string website);

        IEnumerable<Article> GetDrafts(string website, int pageIndex, int pageSize, out int totalRecords);
        
        /// <summary>
        /// Get children posts  under specified category id.
        /// </summary>
        /// <param name="categoryID"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRecords"></param>
        /// <returns></returns>
        IEnumerable<Article> GetCategoryPosts(int categoryID, int pageIndex, int pageSize, out int totalRecords);

        //IEnumerable<Article> GetRecentPosts(int categoryID);

        IEnumerable<Article> GetRecentPosts(int pageIndex, int pageSize, out int totalRecords);

        IEnumerable<Article> GetRecentPosts(string website, int pageIndex, int pageSize, out int totalRecords);

        #endregion

        #region Comment

        Comment AddComment(Comment comment);

        void DeleteComment(int id);

        IEnumerable<Comment> GetRecentComments(string website,int maxResults);

        IEnumerable<Comment> GetUnapproveComments(string id);

        #endregion

        #region Blogs

        IEnumerable<Blog> GetUserBlogs(string userName);

        IEnumerable<Blog> GetBlogs();

        IEnumerable<Blog> GetBlogs(int pageIndex, int pageSize, out int totalRecords);

        #endregion

        IEnumerable<Archive> GetArchives(string website);

        IEnumerable<Tag> GetTags(string website, out int count);

        string SaveMedia(string website, string filename, byte[] data, string contentType);

        TranslatedCopy Translate(TranslatedCopy copy);

        //bool IsSpammer(HttpContextBase httpContext);
        
        //bool IsSpammer(string ip,string url);

        //IQueryable<Spam> GetSpammers();

        //Spam MarkSpammer(Spam spammer);

        Comment FindComment(int id);

       // void DeleteComment(int id);
    }
}
